<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<style>
    .is-hidden {
        display: none;
    }

    .btn {
        background: #ccc;
        border-radius: 3px;
        display: inline-block;
        padding: 5px;
    }

    body {
        padding: 40px;
    }
</style>

<body>
    <span class="js-btn btn">Click me</span>
    <div class='js-fade is-hidden'>You look amazing!</div>
</body>
<script>
    // fade out

    function fadeOut(el) {
        el.style.opacity = 1;

        (function fade() {
            if ((el.style.opacity -= .1) < 0) {
                el.style.display = 'none';
                el.classList.add('is-hidden');
            } else {
                requestAnimationFrame(fade);
            }
        })();
    }

    // fade in

    function fadeIn(el, display) {
        if (el.classList.contains('is-hidden')) {
            el.classList.remove('is-hidden');
        }
        el.style.opacity = 0;
        el.style.display = display || "block";

        (function fade() {
            var val = parseFloat(el.style.opacity);
            if (!((val += .1) > 1)) {
                el.style.opacity = val;
                requestAnimationFrame(fade);
            }
        })();
    }

    var btn = document.querySelector('.js-btn');
    var el = document.querySelector('.js-fade');
    

    console.log(el.classList);
    btn.addEventListener('click', function (e) {
        if (el.classList.contains('is-hidden')) {
            fadeIn(el);
        }
        else {
            fadeOut(el);
        }
    });
    console.log(btn);
</script>

</html>